import dayjs from 'dayjs'
import utils from "./utils.js"
export function formDateSex(value) {
	let sex = "男";
	switch (value) {
		case 0:
			sex = '未知';
			break;
		case 2:
			sex = '女';
			break;
		default:
			break;
	}
	return sex;
}

export function dateFormat(val) {
	if (val != null) {
		return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
	} else {
		return "暂无数据"
	}
}

// 巡检时间
export function datetime(val) {
	if (val != null) {
		return dayjs(val).format('YYYY-MM-DD HH:mm:ss')
	} else {
		return "暂无数据"
	}
}


// 任务时间
export function taskDate(val) {
	if (val != null) {
		return dayjs(val).format('HH:mm:ss')
	} else {
		return "暂无数据"
	}
}


export function hideCodeFilter(val) {
	if (val != null) {
		if (val.length < 8) {
			return utils.hideCode(val, 2, 1)
		} else {
			return utils.hideCode(val, 3, 4)
		}
	} else {
		return null;
	}

}

//维保工单状态
export function workOrderStatus(val) {
	let workOrderStatus = "";
	switch (val) {
		case 0:
			workOrderStatus = '已上报';
			break;
		case 1:
			workOrderStatus = '分配完成';
			break;
		case 2:
			workOrderStatus = '维保等待';
			break;
		case 3:
			workOrderStatus = '维保完成';
			break;
		default:
			break;

	}
	return workOrderStatus;
}
export function fireStatus(val) {
	let fireStatus = "";
	switch (val) {
		case 0:
			fireStatus = "火情已发生"
			break;
		case 1:
			fireStatus = "演练已发起"
			break;
		case 2:
			fireStatus = "火情已结束"
			break;
		default:
			break;
	}
	return fireStatus;
}
export function drillStatus(val) {
	let drillStatus = "";
	switch (val) {
		case 0:
			drillStatus = "演练已发起"
			break;
		case 1:
			drillStatus = "演练已发起"
			break;
		case 2:
			drillStatus = "演练已结束"
			break;
		default:
			break;
	}
	return drillStatus;
}
//维保工单任务状态
export function maintenanceTaskStatus(val) {
	let maintenanceTaskStatus = "";
	switch (val) {
		case 0:
			maintenanceTaskStatus = '未分配';
			break;
		case 1:
			maintenanceTaskStatus = '已分配待执行';
			break;
		case 2:
			maintenanceTaskStatus = '确认任务';
			break;
		case 3:
			maintenanceTaskStatus = '开始执行';
			break;
		case 4:
			maintenanceTaskStatus = '执行中';
			break;
		case 5:
			maintenanceTaskStatus = '执行完成';
			break;
		default:
			break;

	}
	return maintenanceTaskStatus;
}

export function fireResistantLevel(val) {
	let fireResistantLevel = "";
	switch (val) {
		case 1:
			fireResistantLevel = '一级耐火等级建筑';
			break;
		case 2:
			fireResistantLevel = '二级耐火等级建筑';
			break;
		case 3:
			fireResistantLevel = '三级级耐火等级建筑';
			break;
		case 4:
			fireResistantLevel = '四级级耐火等级建筑';
			break;
		default:
			break;
	}
	return fireResistantLevel;
}

// 设备状态
export function status(val) {
	let status = "";
	switch (val) {
		case 0:
			status = '在线';
			break;
		case 1:
			status = '离线';
			break;
		default:
			break;
	}
	return status;
}

// 维保类型
export function maintenanceType(val) {
	let maintenanceType = "";
	switch (val) {
		case 0:
			maintenanceType = '正常维护';
			break;
		case 1:
			maintenanceType = '维修机器';
			break;
		case 2:
			maintenanceType = '更换机器';
			break;
		default:
			break;
	}
	return maintenanceType;
}

// 维保状态
export function maintenanceStatus(val) {
	let maintenanceStatus = "";
	switch (val) {
		case 0:
			maintenanceStatus = '未维护';
			break;
		case 1:
			maintenanceStatus = '维护中';
			break;
		case 2:
			maintenanceStatus = '维护完成';
			break;
		default:
			break;
	}
	return maintenanceStatus;
}

// 巡检设备状态
export function equipmentStatus(val) {
	let equipmentStatus = "";
	switch (val) {
		case 0:
			equipmentStatus = '正常';
			break;
		case 1:
			equipmentStatus = '停机';
			break;
		case 2:
			equipmentStatus = '损坏';
			break;
		default:
			break;
	}
	return equipmentStatus;
}

// 巡检维护状态
export function maintainStatus(val) {
	let maintainStatus = "";
	switch (val) {
		case 0:
			maintainStatus = '是';
			break;
		case 1:
			maintainStatus = '否';
			break;
		default:
			break;
	}
	return maintainStatus;
}

// 预警反馈类型
export function feedtype(val) {
	let feedtype = "";
	switch (val) {
		case 0:
			feedtype = '误报';
			break;
		case 1:
			feedtype = '故障';
			break;
		case 2:
			feedtype = '火情';
			break;
		default:
			break;
	}
	return feedtype;
}

// 任务状态
export function taskStatus(val) {
	let taskStatus = "未知";
	switch (val) {
		case 0:
			taskStatus = '已下发';
			break;
		case 1:
			taskStatus = '进行中';
			break;
		case 2:
			taskStatus = '延迟';
			break;
		case 3:
			taskStatus = '已完成';
			break;
		case 4:
			taskStatus = '已取消';
			break;
		default:
			break;
	}
	return taskStatus;
}


export function dailyTaskStatus(val) {
	let status = "未知";
	switch (val) {
		case 0:
			status = '未领取';
			break;
		case 1:
			status = '已领取';
			break;
		default:
			break;
	}
	return status;
}

// 任务类型
export function type(val) {
	let type = "";
	switch (val) {
		case 0:
			type = '巡检任务';
			break;
		case 1:
			type = '疏散任务';
			break;
		case 2:
			type = '微型消防站任务 ';
			break;
		case 3:
			type = '消防监控室任务';
			break;
		case 4:
			type = '消防通道疏通任务';
			break;
		case 5:
			type = '消防泵房任务';
			break;
		case 6:
			type = '配电室任务';
			break;
		case 7:
			type = '罐区任务';
			break;
		case 10:
			type = '夜保任务';
			break;
		default:
			break;
	}
	return type;
}

export function noticeFeedback(val) {
	let noticeFeedback = "";
	switch (val) {
		case 0:
			noticeFeedback = '未反馈';
			break;
		case 1:
			noticeFeedback = '已反馈';
			break;
		default:
			break;
	}
	return noticeFeedback;
}

export function handleStatus(val) {
	let noticeFeedback = "";
	switch (val) {
		case 0:
			noticeFeedback = '未处置';
			break;
		case 1:
			noticeFeedback = '处置中';
			break;
		case 2:
			noticeFeedback = '处置完成';
			break;
		default:
			break;
	}
	return noticeFeedback;
}
// export function noticeType(val) {
// 	let type = "系统通知";
// 	switch (val) {
// 		case 0:
// 			type = '系统通知';
// 			break;

// 		default:
// 			break;
// 	}
// 	return type;
// }
export function signType(val){
    let signType = "";
    switch (val){
        case "0":
            signType = "上班签到";
            break;
        case "1":
            signType = "下班签退";
            break;
        default:
            break;
    }
    return signType;
}
export default {
	install(Vue) {
		Vue.filter('formDateSex', formDateSex)
		Vue.filter('dateFormat', dateFormat)
		Vue.filter('datetime', datetime)
		Vue.filter('hideCodeFilter', hideCodeFilter)
		Vue.filter('fireResistantLevel', fireResistantLevel)
		Vue.filter('status', status)
		Vue.filter('maintenanceType', maintenanceType)
		Vue.filter('maintenanceStatus', maintenanceStatus)
		Vue.filter('equipmentStatus', equipmentStatus)
		Vue.filter('maintainStatus', maintainStatus)
		Vue.filter('feedtype', feedtype)
		Vue.filter('taskStatus', taskStatus)
		Vue.filter('dailyTaskStatus', dailyTaskStatus)
		Vue.filter('type', type)
		Vue.filter('noticeFeedback', noticeFeedback)
		vue.filter('workOrderStatus', workOrderStatus)
		Vue.filter('taskDate', taskDate)
		Vue.filter('fireStatus', fireStatus)
		Vue.filter('drillStatus', drillStatus)
		Vue.filter('signType', signType)
	}
}
